package com.huanxing.cloud.upms.admin.controller;

import com.huanxing.cloud.common.core.entity.R;
import com.huanxing.cloud.upms.common.entity.SysUser;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** @Author lijx @Date 2022/1/27 16:18 */
@RestController
@RequestMapping("/user")
public class SysUserController {

  @GetMapping("/getUserInfo")
  public R getUserInfo() {
    SysUser sysUser = new SysUser();
    sysUser.setId("1");
    sysUser.setUsername("admin");
    sysUser.setAvatar("https://jycloud-skl.oss-cn-beijing.aliyuncs.com/1/material/7bbaa490-014b-4c6f-8650-ac5c3a4213eb.png");
    BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    // 加密
    String encodedPassword = passwordEncoder.encode("123456");
    sysUser.setPassword(encodedPassword);
    String[] roles = {"ADMIN"};
    sysUser.setRoles(roles);
    String[] permissions = {"upms:sysuser:get"};
    sysUser.setPermissions(permissions);
    return R.success(sysUser);
  }
}
